﻿#region

using System;
using System.Collections.Generic;
using BusinessObjects;
using DataAccessLayer;

#endregion

namespace BusinessLogicLayer
{
    public static class VehicleBLL
    {
        /// <summary>
        ///     Register a vehicle
        /// </summary>
        /// <param name="regNo">Represent's the registration number</param>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        /// <param name="supervisorId">Represent's the supervisor id</param>
        /// <param name="type">Represent's the vehicle type</param>
        public static void RegisterVehicle(string regNo, byte subsidiaryId, int supervisorId, string type)
        {
            Vehicle vehicle = new Vehicle
            {
                RegistrationNo = regNo,
                SubsidiaryId = subsidiaryId,
                SupervisorId = supervisorId,
                Type = type
            };

            VehicleDAL.RegisterVehicle(vehicle);
        }

        /// <summary>
        ///     Get All vehicles
        /// </summary>
        /// <returns>All vehicles</returns>
        public static List<Vehicle> GetAllVehicles()
        {
            return VehicleDAL.GetAllVehicles();
        }

        /// <summary>
        ///     Get All vehicles by subsidiary id
        /// </summary>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        /// <returns>All vehicles</returns>
        public static List<Vehicle> GetAllVehicles(byte subsidiaryId)
        {
            return VehicleDAL.GetAllVehicles(subsidiaryId);
        }

        /// <summary>
        ///     Check whether the vehicle already registered
        /// </summary>
        /// <param name="regNo">Represent's the vehicle registration number</param>
        /// <returns>Registered or not</returns>
        public static bool IsAlreadyRegistered(string regNo)
        {
            return VehicleDAL.IsAlreadyRegistered(regNo);
        }

        /// <summary>
        ///     Edit vehicle's details
        /// </summary>
        /// <param name="regNo">Represent's the registration number</param>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        /// <param name="supervisorId">Represent's the supervisor id</param>
        /// <param name="type">Represent's the vehicle type</param>
        public static void EditVehicle(string regNo, byte subsidiaryId, int supervisorId, string type)
        {
            Vehicle vehicle = new Vehicle
            {
                RegistrationNo = regNo,
                SubsidiaryId = subsidiaryId,
                SupervisorId = supervisorId,
                Type = type
            };

            VehicleDAL.EditVehicle(vehicle);
        }

        /// <summary>
        ///     Get vehicle by registration number
        /// </summary>
        /// <returns>Vehicle</returns>
        public static Vehicle GetVehiclesByRegNo(string registrationNo)
        {
            return VehicleDAL.GetVehiclesByRegNo(registrationNo);
        }

        /// <summary>
        ///     Remove a vehicle
        /// </summary>
        /// <param name="regNo">Represent's the vehicle registration number</param>
        public static void RemoveVehicle(string regNo)
        {
            VehicleDAL.RemoveVehicle(regNo);
        }

        /// <summary>
        ///     Set vehicle's availability (True / False)
        /// </summary>
        /// <param name="registrationNo">Represent's the vehicle's registration number</param>
        /// <param name="status">Represent's the vehicle's availability</param>
        public static void SetAvailability(string registrationNo, bool status)
        {
            Vehicle vehicle = new Vehicle
            {
                RegistrationNo = registrationNo,
                Availability = status
            };

            VehicleDAL.SetAvailability(vehicle);
        }

        /// <summary>
        ///     Get All available vehicles by types for booking
        /// </summary>
        /// <param name="subsidiaryId">Represent's the subsidiary id</param>
        /// <param name="type">Represent's the vehicle type (Van / Car)</param>
        /// <param name="pickupDateTime">Represent's the pickup date and time</param>
        /// <returns>Vehicles</returns>
        public static List<Vehicle> GetAllVehicles(byte subsidiaryId, string type, DateTime pickupDateTime)
        {
            return VehicleDAL.GetAllVehicles(subsidiaryId, type, pickupDateTime);
        }
    }
}